package com.cxyjy.pptdemoapi.controller;

import com.cxyjy.common.util.JResponse;
import com.cxyjy.pptdemoapi.service.PPTCreateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;

/**
 * @Author: JrsJony
 * @Date : 2025/1/20 9:07
 */
@Slf4j
@RestController
public class PPTCreateController {
    @Autowired
    PPTCreateService pptCreateService;
    /**
     * 生成PPT大纲
     * @param usrText
     * @return
     * @throws IOException
     */
    @PostMapping("/createOutline")
    public void createOutline(@RequestParam String usrText, HttpServletResponse response) throws IOException, NoSuchAlgorithmException, KeyManagementException {
        pptCreateService.createOutline(usrText,response);
    }

    @PostMapping("/createPpt")
    public void createPpt(String usrText, @RequestParam String conversationId, HttpServletResponse response) throws IOException, NoSuchAlgorithmException, KeyManagementException {
        pptCreateService.createPpt(usrText,conversationId,response);
    }

    @PostMapping("/zhipuFileUpload")
    public JResponse zhipuFileUpload(MultipartFile file, String purpose) throws IOException {
        return pptCreateService.zhipuFileUpload(file,purpose);
    }
}
